<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>outputAttributes</title>
</head>

<body>
    <div class="test">查看浏览器控制台</div>
    <script>
        const outputAttributes = element => {
            const res = {};
            for (let i = 0, len = element.attributes.length; i < len; i++) {
                const attribute = element.attributes[i];
                res[attribute.nodeName] = attribute.nodeValue;
            }

            return res;
        };
        console.log(outputAttributes(document.querySelector('.test')))
    </script>
</body>

</html>